package com.woniuxy.bankb.controller;

import com.woniuxy.bankb.service.BankBService;
import com.woniuxy.commons.entity.Bank;
import com.woniuxy.commons.util.ResponseResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author zhangyong
 * @Date 2021/8/9 0009下午 2:48
 */
@RestController
@RequestMapping("/bankb")
public class BankBController {
    @Resource
    private BankBService bankBService;

    @GetMapping("/update/{id}/{money}")
    public ResponseResult<String> update(@PathVariable("id") int id, @PathVariable("money") int money) {

        ResponseResult<String> responseResult = new ResponseResult<>();
        responseResult.setCode(200);
        responseResult.setMessage("fail");

        Bank bank = new Bank(id, money, null);
        int result = bankBService.update(bank);
        if (result >= 1) {
            //成功
            responseResult.setMessage("success");
            return responseResult;
        }
        return responseResult;
    }
}
